Am I writing this right? [noob]

Posted by Aaron on Stack Overflow See other posts from Stack Overflow or by Aaron
Published on 2010-05-12T07:45:31Z Indexed on 2010/05/12 7:54 UTC
Read the original article Hit count: 214

Filed under:
|
|
|
|
 private final int NUM_SOUND_FILES = 4;
 private Random rnd = new Random(4);
 private int mfile[] = new mfile[NUM_SOUND_FILES]; //the second mfile 
                                                      //reports error everytime
 mfile[0] = R.raw.sound1;
 mfile[1] = R.raw.sound2;
 mfile[2] = R.raw.sound3;
 mfile[3] = R.raw.sound4;

 int sndToPlay = rnd.nextInt(NUM_SOUND_FILES);

I keep getting syntax errors no matter how I write it. And when I get the syntax right, it forcecloses. Here's with the alleged "correct" syntax but forcecloses:

private final int NUM_SOUND_FILES = 4;
private Random rnd = new Random(4);
private int mfile[] = new int[NUM_SOUND_FILES];{
mfile[0] = R.raw.sound1;
mfile[1] = R.raw.sound2;
mfile[2] = R.raw.sound3;
mfile[3] = R.raw.sound4;}

© Stack Overflow or respective owner

Related posts about random

Related posts about sound